
#include "CWnd.h"

HWND CWnd::Create(LPCTSTR lpTitle, DWORD dwStyle, int x, int y, int w, int h,
    HWND hParent, HMENU hMenu, LPVOID * lpParam) {
  return ::CreateWindow("WINDOW", lpTitle, dwStyle, x, y, w, h, hParent,
      hMenu, GetModuleHandle(NULL), lpParam);
}

BOOL CWnd::Destroy() {
  return ::DestroyWindow(m_hWnd);
}

BOOL CWnd::SetMenu(HMENU hMenu) {
  return ::SetMenu(m_hWnd, hMenu);
}

HMENU CWnd::GetMenu() {
  return ::GetMenu(m_hWnd);
}

BOOL CWnd::GetMenuBarInfo(LONG idObject, LONG idItem, PMENUBARINFO pmbi) {
  return ::GetMenuBarInfo(m_hWnd, idObject, idItem, pmbi);
}

HDC CWnd::BeginPaint(LPPAINTSTRUCT lpPaint) {
  return ::BeginPaint(m_hWnd, lpPaint);
}

BOOL CWnd::EndPaint(LPPAINTSTRUCT lpPaint) {
  return ::EndPaint(m_hWnd, lpPaint);
}

BOOL CWnd::GetWindowRect(LPRECT lpRect) {
  return ::GetWindowRect(m_hWnd, lpRect);
}

BOOL CWnd::GetClientRect(LPRECT lpRect) {
  return ::GetClientRect(m_hWnd, lpRect);
}

BOOL CWnd::Show(int nCmdShow) {
  return ::ShowWindow(m_hWnd, nCmdShow);
}

BOOL CWnd::Update() {
  return ::UpdateWindow(m_hWnd);
}

BOOL CWnd::Move(int x, int y, int w, int h, BOOL bRepaint) {
  return ::MoveWindow(m_hWnd, x, y, w, h, bRepaint);
}

UINT CWnd::SetTimer(UINT nIDEvent, UINT uElapse, TIMERPROC lpTimerFunc) {
  return ::SetTimer(m_hWnd, nIDEvent, uElapse, lpTimerFunc);
}

BOOL CWnd::KillTimer(UINT nIDEvent) {
  return ::KillTimer(m_hWnd, nIDEvent);
}

LRESULT CWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) {
  return CMsg::OnMessage(WM_CREATE, 0, (LPARAM)lpCreateStruct);
}

LRESULT CWnd::OnDestroy() {
  return CMsg::OnMessage(WM_DESTROY, 0, 0);
}

LRESULT CWnd::OnClose() {
  return CMsg::OnMessage(WM_CLOSE, 0, 0);
}

LRESULT CWnd::OnEnable(BOOL bEnabled) {
  return CMsg::OnMessage(WM_ENABLE, bEnabled, 0);
}

LRESULT CWnd::OnCommand(INT nSource, INT nID, HWND hCtrl) {
  return CMsg::OnMessage(WM_COMMAND, MAKEWPARAM(nID, nSource), (LPARAM)hCtrl);
}

LRESULT CWnd::OnNotify(INT nID, LPNMHDR pNMH) {
  return CMsg::OnMessage(WM_NOTIFY, nID, (LPARAM)pNMH);
}

LRESULT CWnd::OnShow(BOOL bShow, DWORD dwStatus) {
  return CMsg::OnMessage(WM_SHOWWINDOW, bShow, dwStatus);
}

LRESULT CWnd::OnMove(INT x, INT y) {
  return CMsg::OnMessage(WM_MOVE, 0, MAKELPARAM(x, y));
}

LRESULT CWnd::OnMoving(LPRECT lpRect) {
  return CMsg::OnMessage(WM_MOVING, 0, (LPARAM)lpRect);
}

LRESULT CWnd::OnSize(UINT uType, INT nWidth, INT nHeight) {
  return CMsg::OnMessage(WM_SIZE, uType, MAKELPARAM(nWidth, nHeight));
}

LRESULT CWnd::OnSizing(UINT uType, LPRECT lpRect) {
  return CMsg::OnMessage(WM_SIZING, uType, (LPARAM)lpRect);
}

LRESULT CWnd::OnPaint(HDC hDC) {
  return CMsg::OnMessage(WM_PAINT, 0, 0);
}

LRESULT CWnd::OnErase(HDC hDC) {
  return CMsg::OnMessage(WM_ERASEBKGND, (WPARAM)hDC, 0);
}

LRESULT CWnd::OnEnterSizeMove() {
  return CMsg::OnMessage(WM_ENTERSIZEMOVE, 0, 0);
}

LRESULT CWnd::OnExitSizeMove() {
  return CMsg::OnMessage(WM_EXITSIZEMOVE, 0, 0);
}

LRESULT CWnd::OnSetFocus(HWND hOldWnd) {
  return CMsg::OnMessage(WM_SETFOCUS, (WPARAM)hOldWnd, 0);
}

LRESULT CWnd::OnKillFocus(HWND hNewWnd) {
  return CMsg::OnMessage(WM_KILLFOCUS, (WPARAM)hNewWnd, 0);
}

LRESULT CWnd::OnTimer(UINT nID, TIMERPROC lpTimerProc) {
  return CMsg::OnMessage(WM_TIMER, nID, (LPARAM)lpTimerProc);
}

LRESULT CWnd::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) {
  return CMsg::OnMessage(WM_CHAR, nChar, MAKELPARAM(nRepCnt, nFlags));
}

LRESULT CWnd::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) {
  return CMsg::OnMessage(WM_KEYDOWN, nChar, MAKELPARAM(nRepCnt, nFlags));
}

LRESULT CWnd::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) {
  return CMsg::OnMessage(WM_KEYUP, nChar, MAKELPARAM(nRepCnt, nFlags));
}

LRESULT CWnd::OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) {
  return CMsg::OnMessage(WM_SYSKEYDOWN, nChar, MAKELPARAM(nRepCnt, nFlags));
}

LRESULT CWnd::OnSysKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) {
  return CMsg::OnMessage(WM_SYSKEYUP, nChar, MAKELPARAM(nRepCnt, nFlags));
}

LRESULT CWnd::OnLButtonDown(UINT nFlags, POINT point) {
  return CMsg::OnMessage(WM_LBUTTONDOWN, nFlags, MAKELPARAM(point.x, point.y));
}

LRESULT CWnd::OnLButtonUp(UINT nFlags, POINT point) {
  return CMsg::OnMessage(WM_LBUTTONUP, nFlags, MAKELPARAM(point.x, point.y));
}

LRESULT CWnd::OnLButtonDblClk(UINT nFlags, POINT point) {
  return CMsg::OnMessage(WM_MBUTTONDOWN, nFlags, MAKELPARAM(point.x, point.y));
}

LRESULT CWnd::OnMButtonDown(UINT nFlags, POINT point) {
  return CMsg::OnMessage(WM_MBUTTONDOWN, nFlags, MAKELPARAM(point.x, point.y));
}

LRESULT CWnd::OnMButtonUp(UINT nFlags, POINT point) {
  return CMsg::OnMessage(WM_MBUTTONUP, nFlags, MAKELPARAM(point.x, point.y));
}

LRESULT CWnd::OnMButtonDblClk(UINT nFlags, POINT point) {
  return CMsg::OnMessage(WM_MBUTTONDBLCLK, nFlags,
      MAKELPARAM(point.x, point.y));
}

LRESULT CWnd::OnRButtonDown(UINT nFlags, POINT point) {
  return CMsg::OnMessage(WM_RBUTTONDOWN, nFlags, MAKELPARAM(point.x, point.y));
}

LRESULT CWnd::OnRButtonUp(UINT nFlags, POINT point) {
  return CMsg::OnMessage(WM_RBUTTONUP, nFlags, MAKELPARAM(point.x, point.y));
}

LRESULT CWnd::OnRButtonDblClk(UINT nFlags, POINT point) {
  return CMsg::OnMessage(WM_RBUTTONDBLCLK, nFlags,
      MAKELPARAM(point.x, point.y));
}

LRESULT CWnd::OnMouseMove(UINT nFlags, POINT point) {
  return CMsg::OnMessage(WM_MOUSEMOVE, nFlags, MAKELPARAM(point.x, point.y));
}

LRESULT CWnd::OnMouseWheel(UINT nFlags, SHORT nDelta, POINT point) {
  return CMsg::OnMessage(WM_MOUSEWHEEL, MAKEWPARAM(nFlags, nDelta),
      MAKELPARAM(point.x, point.y));
}

LRESULT CWnd::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) {
  switch (uMsg) {
    case WM_CREATE:
      return OnCreate((LPCREATESTRUCT)lParam);
    case WM_DESTROY:
      return OnDestroy();
    case WM_CLOSE:
      return OnClose();
    case WM_ENABLE:
      return OnEnable(wParam);
    case WM_COMMAND:
      return OnCommand(HIWORD(wParam), LOWORD(wParam), (HWND)lParam);
    case WM_NOTIFY:
      return OnNotify(wParam, (LPNMHDR)lParam);
    case WM_SHOWWINDOW:
      return OnShow(wParam, lParam);
    case WM_MOVE:
      return OnMove(LOWORD(lParam), HIWORD(lParam));
    case WM_MOVING:
      return OnMoving((LPRECT)lParam);
    case WM_ENTERSIZEMOVE:
      return OnEnterSizeMove();
    case WM_EXITSIZEMOVE:
      return OnExitSizeMove();
    case WM_SIZE:
      return OnSize(wParam, LOWORD(lParam), HIWORD(lParam));
    case WM_SIZING:
      return OnSizing(wParam, (LPRECT)lParam);
    case WM_PAINT:
      {
        PAINTSTRUCT ps;
        HDC hDC = BeginPaint(&ps);
        int nRet = OnPaint(hDC);
        EndPaint(&ps);
        return nRet;
      }
      break;
    case WM_ERASEBKGND:
      return OnErase((HDC)wParam);
    case WM_SETFOCUS:
      return OnSetFocus((HWND)wParam);
    case WM_KILLFOCUS:
      return OnKillFocus((HWND)wParam);
    case WM_TIMER:
      return OnTimer(wParam, (TIMERPROC)lParam);
    case WM_CHAR:
      return OnChar(wParam, LOWORD(lParam), HIWORD(lParam));
    case WM_KEYDOWN:
      return OnKeyDown(wParam, LOWORD(lParam), HIWORD(lParam));
    case WM_KEYUP:
      return OnKeyUp(wParam, LOWORD(lParam), HIWORD(lParam));
    case WM_SYSKEYDOWN:
      return OnSysKeyDown(wParam, LOWORD(lParam), HIWORD(lParam));
    case WM_SYSKEYUP:
      return OnSysKeyUp(wParam, LOWORD(lParam), HIWORD(lParam));
    case WM_LBUTTONDOWN:
      return OnLButtonDown(wParam, {LOWORD(lParam), HIWORD(lParam)});
    case WM_LBUTTONUP:
      return OnLButtonUp(wParam, {LOWORD(lParam), HIWORD(lParam)});
    case WM_LBUTTONDBLCLK:
      return OnLButtonDblClk(wParam, {LOWORD(lParam), HIWORD(lParam)});
    case WM_MBUTTONDOWN:
      return OnMButtonDown(wParam, {LOWORD(lParam), HIWORD(lParam)});
    case WM_MBUTTONUP:
      return OnMButtonUp(wParam, {LOWORD(lParam), HIWORD(lParam)});
    case WM_MBUTTONDBLCLK:
      return OnMButtonDblClk(wParam, {LOWORD(lParam), HIWORD(lParam)});
    case WM_RBUTTONDOWN:
      return OnRButtonDown(wParam, {LOWORD(lParam), HIWORD(lParam)});
    case WM_RBUTTONUP:
      return OnRButtonUp(wParam, {LOWORD(lParam), HIWORD(lParam)});
    case WM_RBUTTONDBLCLK:
      return OnRButtonDblClk(wParam, {LOWORD(lParam), HIWORD(lParam)});
    case WM_MOUSEMOVE:
      return OnMouseMove(wParam, {LOWORD(lParam), HIWORD(lParam)});
    case WM_MOUSEWHEEL:
      return OnMouseWheel(LOWORD(wParam), HIWORD(wParam), {LOWORD(lParam),
          HIWORD(lParam)});
  }
  return CMsg::OnMessage(uMsg, wParam, lParam);
}

